package com.erlang.springmvc.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.HashMap;
import java.util.Map;

/**
 * @Description：动态路径匹配
 */
@Controller
@RequestMapping(value = "doUrl")
public class DoUrlController {

    @RequestMapping(value = "{matchUrl}")
    public ModelAndView matchUrl() {
        //构建对象视图对象
        ModelAndView modelAndView = new ModelAndView();
        //指定视图
        modelAndView.setViewName("succeed");
        //传递参数，接受map对象
        Map<String, Object> map = new HashMap<>();
        map.put("content", "动态路径");
        modelAndView.addAllObjects(map);
        return modelAndView;
    }

    @RequestMapping(value = "{matchUr1}/{matchUr12}")
    public ModelAndView matchUrl2() {
        //构建对象视图对象
        ModelAndView modelAndView = new ModelAndView();
        //指定视图
        modelAndView.setViewName("succeed");
        //传递参数，接受map对象
        Map<String, Object> map = new HashMap<>();
        map.put("content", "动态路径2");
        modelAndView.addAllObjects(map);
        return modelAndView;
    }
}

